package main

import (
    "net/http"
    "log"
	"fmt"
	"time"
	"sync"
)

type TestHandler struct {
    str string
}

func sayHello(w http.ResponseWriter, r *http.Request){
    log.Printf("[HandleFunc]: this is response ")
    w.Write([]byte(string("HandleFunc")))
}

func login(w http.ResponseWriter, r *http.Request) {
    log.Printf("login")
    time.Sleep(time.Second * 3)
	w.Write([]byte(string("post")))
	r.ParseForm()
	fmt.Println(r.Form)
	fmt.Println(r.Form["name"])
    fmt.Println(r.Form["age"])
}

var wc sync.WaitGroup

func main() {
    server := &http.Server{
        Addr:"127.0.0.1:9098",
        ReadTimeout:  2 * time.Second,
        WriteTimeout:  2 * time.Second,
    }

    mux := http.NewServeMux()
    mux.HandleFunc("/", login)
    mux.HandleFunc("/login", login)
    mux.HandleFunc("/hello/sayhello", sayHello)
    server.Handler = mux
    server.ListenAndServe()
}

